/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */


//otro hola mundo para update

package jugueteria_lm;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;

/**
 *
 * @author Gorda
 */
public class Cliente_Empleado extends javax.swing.JFrame {

    /**
     * Creates new form Cliente_Empleado
     */
    Jugueteria_Datos obj = new Jugueteria_Datos();
    Conexion conectar = new Conexion();

    public Cliente_Empleado() {
        initComponents();
        MostrarCliente("");
        MostrarEmpleado("");
    }

    
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPopupMenu1 = new javax.swing.JPopupMenu();
        Actualizar = new javax.swing.JMenuItem();
        Eliminar = new javax.swing.JMenuItem();
        jPDevol = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        Tabla_cliente = new javax.swing.JTable();
        jScrollPane2 = new javax.swing.JScrollPane();
        Templeado = new javax.swing.JTable();
        jButton1 = new javax.swing.JButton();
        camp3 = new javax.swing.JTextField();
        camp1 = new javax.swing.JTextField();
        camp4 = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jButton2 = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();
        jButton4 = new javax.swing.JButton();
        jButton5 = new javax.swing.JButton();
        jTBusca = new javax.swing.JTextField();
        jButton6 = new javax.swing.JButton();
        jLabel4 = new javax.swing.JLabel();
        camp2 = new javax.swing.JTextField();
        jButton7 = new javax.swing.JButton();
        jButton8 = new javax.swing.JButton();
        jButton9 = new javax.swing.JButton();
        jButton10 = new javax.swing.JButton();
        jButton11 = new javax.swing.JButton();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        emp1 = new javax.swing.JTextField();
        emp2 = new javax.swing.JTextField();
        emp4 = new javax.swing.JTextField();
        emp3 = new javax.swing.JTextField();
        emp5 = new javax.swing.JTextField();
        buscaemp = new javax.swing.JTextField();
        jButton12 = new javax.swing.JButton();
        jButton13 = new javax.swing.JButton();
        jLabel11 = new javax.swing.JLabel();

        Actualizar.setText("Modificar");
        Actualizar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ActualizarActionPerformed(evt);
            }
        });
        jPopupMenu1.add(Actualizar);

        Eliminar.setText("Eliminar");
        Eliminar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                EliminarActionPerformed(evt);
            }
        });
        jPopupMenu1.add(Eliminar);

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jPDevol.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        Tabla_cliente.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {

            }
        ));
        Tabla_cliente.setComponentPopupMenu(jPopupMenu1);
        jScrollPane1.setViewportView(Tabla_cliente);

        jPDevol.add(jScrollPane1, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 76, 599, 145));

        Templeado.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {

            }
        ));
        jScrollPane2.setViewportView(Templeado);

        jPDevol.add(jScrollPane2, new org.netbeans.lib.awtextra.AbsoluteConstraints(230, 290, 539, 155));

        jButton1.setText("Mostrar Empleado");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });
        jPDevol.add(jButton1, new org.netbeans.lib.awtextra.AbsoluteConstraints(230, 260, -1, -1));

        camp3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                camp3ActionPerformed(evt);
            }
        });
        jPDevol.add(camp3, new org.netbeans.lib.awtextra.AbsoluteConstraints(417, 43, 43, -1));

        camp1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                camp1ActionPerformed(evt);
            }
        });
        jPDevol.add(camp1, new org.netbeans.lib.awtextra.AbsoluteConstraints(308, 43, 45, -1));
        jPDevol.add(camp4, new org.netbeans.lib.awtextra.AbsoluteConstraints(478, 43, 53, -1));

        jLabel1.setForeground(new java.awt.Color(255, 255, 255));
        jLabel1.setText("Telefono");
        jPDevol.add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(478, 23, -1, -1));

        jLabel2.setForeground(new java.awt.Color(255, 255, 255));
        jLabel2.setText("Direccion");
        jPDevol.add(jLabel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(417, 23, -1, -1));

        jLabel3.setForeground(new java.awt.Color(255, 255, 255));
        jLabel3.setText("ID");
        jPDevol.add(jLabel3, new org.netbeans.lib.awtextra.AbsoluteConstraints(317, 23, -1, -1));

        jButton2.setText("Nuevo");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });
        jPDevol.add(jButton2, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 11, -1, -1));

        jButton3.setText("Agregar");
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });
        jPDevol.add(jButton3, new org.netbeans.lib.awtextra.AbsoluteConstraints(126, 11, -1, -1));

        jButton4.setText("Actualizar");
        jButton4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton4ActionPerformed(evt);
            }
        });
        jPDevol.add(jButton4, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 40, -1, -1));

        jButton5.setText("Buscar");
        jButton5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton5ActionPerformed(evt);
            }
        });
        jPDevol.add(jButton5, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 227, -1, -1));
        jPDevol.add(jTBusca, new org.netbeans.lib.awtextra.AbsoluteConstraints(101, 228, 58, -1));

        jButton6.setText("Mostrar");
        jButton6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton6ActionPerformed(evt);
            }
        });
        jPDevol.add(jButton6, new org.netbeans.lib.awtextra.AbsoluteConstraints(126, 40, -1, -1));

        jLabel4.setForeground(new java.awt.Color(255, 255, 255));
        jLabel4.setText("Cliente");
        jPDevol.add(jLabel4, new org.netbeans.lib.awtextra.AbsoluteConstraints(364, 23, -1, -1));
        jPDevol.add(camp2, new org.netbeans.lib.awtextra.AbsoluteConstraints(363, 43, 48, -1));

        jButton7.setText("Actualizar");
        jButton7.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton7ActionPerformed(evt);
            }
        });
        jPDevol.add(jButton7, new org.netbeans.lib.awtextra.AbsoluteConstraints(25, 363, -1, -1));

        jButton8.setText("Agregar");
        jButton8.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton8ActionPerformed(evt);
            }
        });
        jPDevol.add(jButton8, new org.netbeans.lib.awtextra.AbsoluteConstraints(670, 470, 79, -1));

        jButton9.setText("Eliminar");
        jButton9.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton9ActionPerformed(evt);
            }
        });
        jPDevol.add(jButton9, new org.netbeans.lib.awtextra.AbsoluteConstraints(122, 363, 79, -1));

        jButton10.setText("Buscar");
        jButton10.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton10ActionPerformed(evt);
            }
        });
        jPDevol.add(jButton10, new org.netbeans.lib.awtextra.AbsoluteConstraints(25, 404, 79, -1));

        jButton11.setText("Modificar");
        jButton11.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton11ActionPerformed(evt);
            }
        });
        jPDevol.add(jButton11, new org.netbeans.lib.awtextra.AbsoluteConstraints(25, 445, -1, -1));

        jLabel5.setForeground(new java.awt.Color(255, 255, 255));
        jLabel5.setText("Id Empleado");
        jPDevol.add(jLabel5, new org.netbeans.lib.awtextra.AbsoluteConstraints(240, 450, -1, -1));

        jLabel6.setForeground(new java.awt.Color(255, 255, 255));
        jLabel6.setText("Nombre");
        jPDevol.add(jLabel6, new org.netbeans.lib.awtextra.AbsoluteConstraints(330, 450, -1, -1));

        jLabel7.setForeground(new java.awt.Color(255, 255, 255));
        jLabel7.setText("Telefono");
        jPDevol.add(jLabel7, new org.netbeans.lib.awtextra.AbsoluteConstraints(440, 450, -1, -1));

        jLabel8.setForeground(new java.awt.Color(255, 255, 255));
        jLabel8.setText("Sueldo");
        jPDevol.add(jLabel8, new org.netbeans.lib.awtextra.AbsoluteConstraints(530, 450, -1, -1));

        jLabel9.setForeground(new java.awt.Color(255, 255, 255));
        jLabel9.setText("Cargo");
        jPDevol.add(jLabel9, new org.netbeans.lib.awtextra.AbsoluteConstraints(590, 450, 47, -1));

        emp1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                emp1ActionPerformed(evt);
            }
        });
        jPDevol.add(emp1, new org.netbeans.lib.awtextra.AbsoluteConstraints(240, 470, 59, -1));
        jPDevol.add(emp2, new org.netbeans.lib.awtextra.AbsoluteConstraints(330, 470, 83, -1));

        emp4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                emp4ActionPerformed(evt);
            }
        });
        jPDevol.add(emp4, new org.netbeans.lib.awtextra.AbsoluteConstraints(530, 470, 52, -1));
        jPDevol.add(emp3, new org.netbeans.lib.awtextra.AbsoluteConstraints(440, 470, 67, -1));
        jPDevol.add(emp5, new org.netbeans.lib.awtextra.AbsoluteConstraints(590, 470, 47, -1));
        jPDevol.add(buscaemp, new org.netbeans.lib.awtextra.AbsoluteConstraints(122, 405, 79, -1));

        jButton12.setText("Nuevo");
        jButton12.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton12ActionPerformed(evt);
            }
        });
        jPDevol.add(jButton12, new org.netbeans.lib.awtextra.AbsoluteConstraints(120, 440, 93, -1));

        jButton13.setBackground(new java.awt.Color(255, 0, 0));
        jButton13.setText("Salir");
        jButton13.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton13ActionPerformed(evt);
            }
        });
        jPDevol.add(jButton13, new org.netbeans.lib.awtextra.AbsoluteConstraints(680, 530, 60, 30));

        jLabel11.setIcon(new javax.swing.ImageIcon(getClass().getResource("/jugueteria_lm/7.jpg"))); // NOI18N
        jLabel11.setText("jLabel11");
        jPDevol.add(jLabel11, new org.netbeans.lib.awtextra.AbsoluteConstraints(-10, 0, 810, 570));

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPDevol, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPDevol, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        // TODO add your handling code here:
        DefaultTableModel ModeloRenta = new DefaultTableModel();

        ModeloRenta.addColumn("ID Empleado");
        ModeloRenta.addColumn("Nombre");
        ModeloRenta.addColumn("Telefono");
        ModeloRenta.addColumn("Sueldo");
        ModeloRenta.addColumn("Cargo");

     

        Templeado.setModel(ModeloRenta);

        String[] datosEmp = new String[5];
        try {
            Statement st = conectar.getConnection().createStatement();
            ResultSet rs = st.executeQuery("SELECT * FROM empleado");
            while (rs.next()) {
                datosEmp[0] = rs.getString(1);
                datosEmp[1] = rs.getString(2);
                datosEmp[2] = rs.getString(3);
                datosEmp[3] = rs.getString(4);
                datosEmp[4] = rs.getString(5);


                ModeloRenta.addRow(datosEmp);

            }
            Tabla_cliente.setModel(ModeloRenta);
        } catch (SQLException ex) {
            System.out.println(ex.getMessage());
        }
    }//GEN-LAST:event_jButton1ActionPerformed

    private void camp3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_camp3ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_camp3ActionPerformed

    private void camp1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_camp1ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_camp1ActionPerformed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        // TODO add your handling code here:
        camp3.setText(null);
        camp4.setText(null);
        camp1.setText(null);
        camp2.setText(null);
    }//GEN-LAST:event_jButton2ActionPerformed

    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
        // TODO add your handling code here:
        try {
            try (PreparedStatement insertar = conectar.getConnection().prepareStatement("insert into cliente(idcliente, nombre, direccion, telefono) "
                            + " values(?,?,?,?)")) {
                insertar.setString(1, camp1.getText());
                insertar.setString(2, camp2.getText());
                insertar.setString(3, camp3.getText());
                insertar.setString(4, camp4.getText());
                insertar.execute();
                insertar.close();
                JOptionPane.showMessageDialog(null, "cliente Agregado");
                MostrarCliente("");
            }
        } catch (SQLException e) {
            System.out.print(e.getMessage());
   
        }

    }//GEN-LAST:event_jButton3ActionPerformed

    private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
        // TODO add your handling code here:

        try {

            PreparedStatement pre = conectar.getConnection().prepareStatement("UPDATE cliente "
                    + "SET nombre='" + camp2.getText() + "', direccion='" + camp3.getText() + "', telefono=" + camp4.getText()
                    + " WHERE idcliente='" + camp1.getText() + "';");
            pre.executeUpdate();

            JOptionPane.showMessageDialog(this, "Se Actualizo con exito");
            MostrarCliente("");
        } catch (SQLException ex) {
            //JOptionPane.showMessageDialog(this, "Error al Corregir");
            System.out.print(ex.getMessage());
        }
    }//GEN-LAST:event_jButton4ActionPerformed

    private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed
        // TODO add your handling code here:

        MostrarCliente(buscaemp.getText());
    }//GEN-LAST:event_jButton5ActionPerformed

    private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton6ActionPerformed
        // TODO add your handling code here:
        MostrarCliente("");
    }//GEN-LAST:event_jButton6ActionPerformed

    private void ActualizarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ActualizarActionPerformed
        // TODO add your handling code here:

        int fila2 = Tabla_cliente.getSelectedRow();
        if (fila2 >= 0) {
            camp1.setText(Tabla_cliente.getValueAt(fila2, 0).toString());
            camp2.setText(Tabla_cliente.getValueAt(fila2, 1).toString());
            camp3.setText(Tabla_cliente.getValueAt(fila2, 2).toString());
            camp4.setText(Tabla_cliente.getValueAt(fila2, 3).toString());

        } else {
            JOptionPane.showMessageDialog(null, "Seleccionado una fila por favor");

        }
    }//GEN-LAST:event_ActualizarActionPerformed

    private void EliminarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_EliminarActionPerformed
        // TODO add your handling code here:
        int fild = Tabla_cliente.getSelectedRow();
        if (fild > -1) {
            String id = String.valueOf(Tabla_cliente.getValueAt(fild, 0));
            obj.Elimina_Datos("cliente", "idcliente", id);
            MostrarCliente("");
            fild = -1;
        }
    }//GEN-LAST:event_EliminarActionPerformed

    private void emp4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_emp4ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_emp4ActionPerformed

    private void jButton8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton8ActionPerformed
        // TODO add your handling code here://Agregar tabla empleado
        try {
            try (PreparedStatement insertar = conectar.getConnection().prepareStatement("insert into empleado(idempleado, nombre, telefono, sueldo, cargo) "
                            + " values(?,?,?,?,?)")) {
                insertar.setString(1, emp1.getText());
                insertar.setString(2, emp2.getText());
                insertar.setString(3, emp3.getText());
                insertar.setString(4, emp4.getText());
                insertar.setString(5, emp5.getText());
                insertar.execute();
                insertar.close();
                JOptionPane.showMessageDialog(null, "empleado Agregado");
                MostrarEmpleado("");
            }
        } catch (SQLException e) {
            System.out.print(e.getMessage());
            //JOptionPane.showMessageDialog(null, "ID (" + camp1.getText() + ") en uso..");
        }

    }//GEN-LAST:event_jButton8ActionPerformed

    private void emp1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_emp1ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_emp1ActionPerformed

    private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton7ActionPerformed
        // TODO add your handling code here://actualizar empleado
        try {

            PreparedStatement pre = conectar.getConnection().prepareStatement("UPDATE empleado "
                    + "SET nombre='" + emp2.getText() + "', telefono='" + emp3.getText() + "', sueldo=" + emp4.getText()
                    + " WHERE idempleado='" + emp1.getText() + "';");
            pre.executeUpdate();

            JOptionPane.showMessageDialog(this, "Se Actualizo Empleado con Exito");
            MostrarEmpleado("");
        } catch (SQLException ex) {
            //JOptionPane.showMessageDialog(this, "Error al Corregir");
            System.out.print(ex.getMessage());
        }

    }//GEN-LAST:event_jButton7ActionPerformed

    private void jButton9ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton9ActionPerformed
        // TODO add your handling code here://eliminar empleado
        int fild = Templeado.getSelectedRow();
        if (fild > -1) {
            String id = String.valueOf(Templeado.getValueAt(fild, 0));
            obj.Elimina_Datos("empleado", "idempleado", id);
            MostrarEmpleado("");
            fild = -1;
        }
    }//GEN-LAST:event_jButton9ActionPerformed

    private void jButton10ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton10ActionPerformed
        // TODO add your handling code here:
        MostrarEmpleado(buscaemp.getText());
    }//GEN-LAST:event_jButton10ActionPerformed

    private void jButton11ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton11ActionPerformed
        // TODO add your handling code here:
        int fila2 = Templeado.getSelectedRow();
        if (fila2 >= 0) {
            emp1.setText(Templeado.getValueAt(fila2, 0).toString());
            emp2.setText(Templeado.getValueAt(fila2, 1).toString());
            emp3.setText(Templeado.getValueAt(fila2, 2).toString());
            emp4.setText(Templeado.getValueAt(fila2, 3).toString());
            emp5.setText(Templeado.getValueAt(fila2, 4).toString());

        } else {
            JOptionPane.showMessageDialog(null, "Seleccionado una fila por favor");

        }
    }//GEN-LAST:event_jButton11ActionPerformed

    private void jButton12ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton12ActionPerformed
        // TODO add your handling code here:
        emp1.setText(null);
        emp2.setText(null);
        emp3.setText(null);
        emp4.setText(null);
        emp5.setText(null);
    }//GEN-LAST:event_jButton12ActionPerformed

    private void jButton13ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton13ActionPerformed
        // TODO add your handling code here:
         this.setVisible(false);
    }//GEN-LAST:event_jButton13ActionPerformed
    void MostrarCliente(String muestra) {
        DefaultTableModel ModeloCliente = new DefaultTableModel();

        ModeloCliente.addColumn("ID Cliente");
        ModeloCliente.addColumn(" Nombre");
        ModeloCliente.addColumn("Direccion");
        ModeloCliente.addColumn("Telefono");

        Tabla_cliente.setModel(ModeloCliente);
        String sql = "";
        if (muestra.equals("")) {

            sql = "SELECT * FROM cliente";
        } else {
            sql = "SELECT * FROM cliente WHERE idcliente ='" + muestra + "'";
        }
        String[] datosempleado = new String[4];
        try {
            Statement st = conectar.getConnection().createStatement();
            ResultSet rs = st.executeQuery(sql);
            while (rs.next()) {
                datosempleado[0] = rs.getString(1);
                datosempleado[1] = rs.getString(2);
                datosempleado[2] = rs.getString(3);
                datosempleado[3] = rs.getString(4);

                ModeloCliente.addRow(datosempleado);

            }
            Tabla_cliente.setModel(ModeloCliente);
        } catch (SQLException ex) {
            System.out.println(ex.getMessage());
        }
    }

    void MostrarEmpleado(String empleado) {
        DefaultTableModel ModeloEmpleado = new DefaultTableModel();

        ModeloEmpleado.addColumn("ID Empleado");
        ModeloEmpleado.addColumn(" Nombre");
        ModeloEmpleado.addColumn("Telefono");
        ModeloEmpleado.addColumn("Sueldo");
        ModeloEmpleado.addColumn("Cargo");

        Templeado.setModel(ModeloEmpleado);
        String sql = "";
        if (empleado.equals("")) {

            sql = "SELECT * FROM empleado";
        } else {
            sql = "SELECT * FROM empleado WHERE idempleado ='" + empleado + "'";
        }
        String[] datosEmpleado = new String[5];
        try {
            Statement stat = conectar.getConnection().createStatement();
            ResultSet rs = stat.executeQuery(sql);
            while (rs.next()) {
                datosEmpleado[0] = rs.getString(1);
                datosEmpleado[1] = rs.getString(2);
                datosEmpleado[2] = rs.getString(3);
                datosEmpleado[3] = rs.getString(4);
                datosEmpleado[4] = rs.getString(5);

                ModeloEmpleado.addRow(datosEmpleado);

            }
            Templeado.setModel(ModeloEmpleado);
        } catch (SQLException ex) {
            System.out.println(ex.getMessage());
        }
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(Cliente_Empleado.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(Cliente_Empleado.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(Cliente_Empleado.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(Cliente_Empleado.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Cliente_Empleado().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JMenuItem Actualizar;
    private javax.swing.JMenuItem Eliminar;
    private javax.swing.JTable Tabla_cliente;
    private javax.swing.JTable Templeado;
    private javax.swing.JTextField buscaemp;
    private javax.swing.JTextField camp1;
    private javax.swing.JTextField camp2;
    private javax.swing.JTextField camp3;
    private javax.swing.JTextField camp4;
    private javax.swing.JTextField emp1;
    private javax.swing.JTextField emp2;
    private javax.swing.JTextField emp3;
    private javax.swing.JTextField emp4;
    private javax.swing.JTextField emp5;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton10;
    private javax.swing.JButton jButton11;
    private javax.swing.JButton jButton12;
    private javax.swing.JButton jButton13;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JButton jButton5;
    private javax.swing.JButton jButton6;
    private javax.swing.JButton jButton7;
    private javax.swing.JButton jButton8;
    private javax.swing.JButton jButton9;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPDevol;
    private javax.swing.JPopupMenu jPopupMenu1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JTextField jTBusca;
    // End of variables declaration//GEN-END:variables
}
